package Database;

import Entity.AccountDetails;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author CONG
 */
public class AccountDetailsDB {

    private ConnectDB conn;

    public AccountDetailsDB() {
        conn = new ConnectDB();
    }

    public ArrayList<AccountDetails> getAccopuntDetailsList() {
        ArrayList<AccountDetails> listAccountDetails = new ArrayList<AccountDetails>();
        try {
            CallableStatement cstmt=conn.connect().prepareCall("{call getAccountDetailsList}");
            ResultSet rs=cstmt.executeQuery();
            while(rs.next()){
            int registerNo=rs.getInt("RegisterNo");
            int accountLoanCode=rs.getInt("AccountLoanCode");
            int branchCode=rs.getInt("Branchcode");
            int period=rs.getInt("Period");
            AccountDetails ad=new AccountDetails(registerNo, accountLoanCode, branchCode, period);
            listAccountDetails.add(ad);
            }
        } catch (Exception ex) {
            Logger.getLogger(AccountDetailsDB.class.getName()).log(Level.SEVERE, null, ex);
        }
        return listAccountDetails;
    }
}
